<template>
	<view>
		<view>
			<u-swiper
				height="350"
				:list="detailInfo.fileUrls"
				indicator
				indicatorMode="line"
				circular
				radius="0"
				@click="handleImage"
			></u-swiper>
		</view>
		
		<view class="info-box row-box">
			<view style="width: 80%;">
				<view class="h2-font">{{detailInfo.modelName}}</view>
				<view>{{detailInfo.specs}}</view>
				<view>IEMI：{{detailInfo.iemi}}</view>
				<view>{{detailInfo.createTime}}</view>
				<view>备注：{{detailInfo.remark}}</view>
			</view>
			<view class="center-box" v-if="!detailInfo.recycleOrderVo">
				<u-tag v-if="!verityTime()" type="warning" text="询价中"></u-tag>
				<u-tag v-if="verityTime()" type="info" plain text="结束"></u-tag>
			</view>
			<view class="center-box" v-else>
				<u-tag v-if="detailInfo.recycleOrderVo.status === 1" type="error" text="待支付"></u-tag>
				<u-tag v-if="detailInfo.recycleOrderVo.status === 2" type="warning" text="待发货"></u-tag>
				<u-tag v-if="detailInfo.recycleOrderVo.status === 3" type="primary" text="待收货"></u-tag>
				<u-tag v-if="detailInfo.recycleOrderVo.status === 4" type="success" text="已完成"></u-tag>
				<u-tag v-if="detailInfo.recycleOrderVo.status === 5" type="info" text="已取消"></u-tag>
			</view>
		</view>
		
		<!-- 回收商端 报价表单 -->
		<view class="price-box" v-if="userInfo.type === 1">
			<view class="row-box">
				<view class="h2-font" style="width: 80%;">我的报价</view>
			</view>
			<view>
				<u--form labelPosition="left">
					<u-form-item label="金额" borderBottom required>
						<u--input type="number" v-model="form.offerPrice" border="none" placeholder="请输入报价金额" :disabled="verityTime() || detailInfo.recycleOrderVo"></u--input>
					</u-form-item>
				</u--form>
			</view>
			
			<view v-if="detailInfo.recycleOrderVo.status >= 3">
				<u-form label-width="100">
					<u-form-item label="收货手机号:">
						{{detailInfo.recycleOrderVo.receivingMobile ? detailInfo.recycleOrderVo.receivingMobile : ''}}
					</u-form-item>
					<u-form-item label="收货地址:">
						{{detailInfo.recycleOrderVo.receivingAddr ? detailInfo.recycleOrderVo.receivingAddr : ''}}
					</u-form-item>
					<u-form-item label="快递单号:">
						{{detailInfo.recycleOrderVo.expressageNo ? detailInfo.recycleOrderVo.expressageNo : ''}}
					</u-form-item>
				</u-form>
			</view>
			
			<view class="row-box" style="margin-top: 10rpx;" v-if="!(verityTime() || detailInfo.recycleOrderVo)">
				<view style="width: 40%;margin-left: 5%;margin-right: 5%;">
					<u-button text="询问" @click="gotoMessage(form.id, detailInfo.userId)"></u-button>
				</view>
				<view style="width: 40%;margin-left: 5%;margin-right: 5%;">
					<u-button text="报价" type="success" plain @click="handleUpdateOffer"></u-button>
				</view>	
			</view>
			
			<view v-if="detailInfo.recycleOrderVo" style="margin-top: 10rpx;">
				<view v-if="detailInfo.recycleOrderVo.status === 1">
					<u-button type="success" text="确定支付" @click="paymentOrder()"></u-button>
				</view>
				
				<view v-if="detailInfo.recycleOrderVo.status === 3">
					<u-button type="primary" text="确定收货" @click="collectOk()"></u-button>
				</view>
				
				<view v-if="detailInfo.recycleOrderVo.status === 4 && (!detailInfo.recycleOrderVo.refundOrderVo && !detailInfo.recycleOrderVo.spreadOrderVo)" class="row-box">
					<view style="width: 40%;margin-left: 5%;margin-right: 5%;">
						<u-button text="发起追差" type="error" plain @click="handleSpread()"></u-button>
					</view>
					<view style="width: 40%;margin-left: 5%;margin-right: 5%;">
						<u-button text="发起退货" type="warning" plain @click="refundOrder()"></u-button>
					</view>	
				</view>
			</view>
			
			<view v-if="detailInfo.recycleOrderVo.refundOrderVo" style="margin-top: 20rpx;">
				<view class="h2-font" style="width: 80%;">退单进度</view>
				<view style="margin-top: 20rpx;">
					<u-steps :current="getStepNumber()">
						<u-steps-item title="发起退单"></u-steps-item>
						<u-steps-item title="对方同意"></u-steps-item>
						<u-steps-item title="完成退单"></u-steps-item>
						<u-steps-item title="对方拒绝"></u-steps-item>
					</u-steps>
				</view>
				
				<view style="padding: 20rpx;" v-if="detailInfo.recycleOrderVo.refundOrderVo.status === 2">
					<u-button @click="handleRefund(3)" plain type="primary" text="完成退单"></u-button>
				</view>
			</view>
			
			<view v-if="detailInfo.recycleOrderVo.spreadOrderVo" style="margin-top: 20rpx;">
				<view class="h2-font" style="width: 80%;">追差进度</view>
				<view style="margin-top: 20rpx;">
					<u-steps :current="getStepNumberS()">
						<u-steps-item title="发起追差"></u-steps-item>
						<u-steps-item title="对方同意"></u-steps-item>
						<u-steps-item title="完成追差"></u-steps-item>
						<u-steps-item title="对方拒绝"></u-steps-item>
					</u-steps>
				</view>
				
				<view>
					<u-form label-width="65">
						<u-form-item label="追差金额">
							{{detailInfo.recycleOrderVo.spreadOrderVo.spread}} 元
 						</u-form-item>
						<u-form-item label="支付截图">
							<view v-if="detailInfo.recycleOrderVo.spreadOrderVo.payImg">
								<u-image 
									:src="detailInfo.recycleOrderVo.spreadOrderVo.payImg" 
									width="160rpx" height="160rpx"
									@click="handleImageOne()"
								></u-image>
							</view>
						</u-form-item>
					</u-form>
				</view>
				
				<view style="padding: 20rpx;" v-if="detailInfo.recycleOrderVo.spreadOrderVo.status === 2">
					<u-button @click="handleSpreadOrder(3)" plain type="primary" text="完成追差"></u-button>
				</view>
			</view>
		</view>
		
		<!-- 门店端 询价列表 -->
		<view v-if="userInfo.type > 1">
			<!-- 回收订单报价详情 -->
			<view v-if="detailInfo.recycleOrderVo">
				<view class="price-box" v-if="centreInfo">
					<view class="h2-font">报价详情</view>
					<view class="info-box row-box">
						<view style="width: 80%;">
							<span style="font-weight: 900;">{{centreInfo.offerBusName}}</span>
							{{' ' + centreInfo.offerOperatorName}}
						</view>
						<view style="color: #fa3534;width: 20%;text-align: right;">￥{{centreInfo.rateAmount ? centreInfo.rateAmount : centreInfo.offerPrice}}</view>
					</view>
					
					<view class="info-box">
						<u-form label-width="100">
							<u-form-item label="收货手机号:">
								{{detailInfo.recycleOrderVo.receivingMobile ? detailInfo.recycleOrderVo.receivingMobile : ''}}
							</u-form-item>
							<u-form-item label="收货地址:">
								{{detailInfo.recycleOrderVo.receivingAddr ? detailInfo.recycleOrderVo.receivingAddr : ''}}
							</u-form-item>
							<u-form-item label="快递单号" required>
								<u-input placeholder="请输入快递单号" v-model="expressageNo" v-if="detailInfo.recycleOrderVo.status === 2"></u-input>
								<view v-else>
									{{detailInfo.recycleOrderVo.expressageNo ? detailInfo.recycleOrderVo.expressageNo : ''}}
								</view>
							</u-form-item>
						</u-form>
						<u-button type="primary" text="确定发货" @click="updateOrderStatus(3)" v-if="detailInfo.recycleOrderVo.status === 2"></u-button>
					</view>
					
					<view class="info-box">
						<u-button type="warning" text="取消回收" plain v-if="detailInfo.recycleOrderVo.status === 1"  @click="updateOrderStatus(5)"></u-button>
						<u-button 
							type="success" 
							text="用户提现" 
							v-if="detailInfo.recycleOrderVo.status > 1 && detailInfo.recycleOrderVo.status < 5 && detailInfo.recycleOrderVo.customerWithdraw.status === 0"
							@click="handleWithdraw()"></u-button>
					</view>
					
					<view v-if="detailInfo.recycleOrderVo.refundOrderVo" style="margin-top: 20rpx;">
						<view class="h2-font">退单进度</view>
						<view style="margin-top: 20rpx;">
							<u-steps :current="getStepNumber()">
								<u-steps-item title="待审核"></u-steps-item>
								<u-steps-item title="同意退单"></u-steps-item>
								<u-steps-item title="完成退单"></u-steps-item>
								<u-steps-item title="拒绝退单"></u-steps-item>
							</u-steps>
						</view>
						<view class="row-box" style="margin-top: 20rpx;" v-if="detailInfo.recycleOrderVo.refundOrderVo.status === 1">
							<view style="padding: 10px;width: 50%;">
								<u-button text="拒绝" plain @click="handleRefund(4)"></u-button>
							</view>
							<view style="padding: 10px;width: 50%;">
								<u-button type="success" plain text="通过" @click="handleRefund(2)"></u-button>
							</view>
						</view>
					</view>
					
					<view v-if="detailInfo.recycleOrderVo.spreadOrderVo" style="margin-top: 20rpx;">
						<view class="h2-font" style="width: 80%;">追差进度</view>
						<view style="margin-top: 20rpx;">
							<u-steps :current="getStepNumberS()">
								<u-steps-item title="待审核"></u-steps-item>
								<u-steps-item title="同意"></u-steps-item>
								<u-steps-item title="完成"></u-steps-item>
								<u-steps-item title="拒绝"></u-steps-item>
							</u-steps>
						</view>
						
						<view>
							<u-form label-width="65">
								<u-form-item label="追差金额">
									{{detailInfo.recycleOrderVo.spreadOrderVo.spread}} 元
								</u-form-item>
								<u-form-item label="支付截图">
									<view v-if="detailInfo.recycleOrderVo.spreadOrderVo.payImg">
										<u-image 
											:src="detailInfo.recycleOrderVo.spreadOrderVo.payImg" 
											width="160rpx" height="160rpx"
											@click="handleImageOne()"
										></u-image>
									</view>
									<view style="margin: 30rpx;" v-else>
										<u-upload
											:fileList="fileList"
											@afterRead="afterRead"
											name="1"
											multiple
											:sizeType="['compressed']"
											:maxCount="1"
										></u-upload>
									</view>
								</u-form-item>
							</u-form>
						</view>
						
						<view class="row-box" style="margin-top: 20rpx;" v-if="detailInfo.recycleOrderVo.spreadOrderVo.status === 1">
							<view style="padding: 10px;width: 50%;">
								<u-button text="拒绝" plain @click="handleSpreadOrder(4)"></u-button>
							</view>
							<view style="padding: 10px;width: 50%;">
								<u-button type="success" plain text="通过" @click="handleSpreadOrder(2)"></u-button>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 回收成功前 报价列表 -->
			<view v-else>
				<view class="price-box" v-if="detailInfo.offerOrderList.length > 0">
					<view class="h2-font" style="width: 80%;">报价列表</view>
					<view 
						v-if="detailInfo"
						class="row-box item-box"
						v-for="(item,key) in detailInfo.offerOrderList"
						@click="priceClick(key)"
					>
						<view style="width: 45%;overflow:hidden">{{item.offerBusName}}</view>
						<view style="color: #fa3534;width: 25%;" class="row-box">
							<span v-if="item.status === 2 && !item.rateAmount">
								￥{{item.offerPrice}}
							</span>
							<span v-if="item.rateAmount">
								￥{{item.rateAmount}}
							</span>
						</view>
						<view style="width: 14%;">
							<u-button size="mini" text="对话" @click="gotoMessage(item.id, item.offerOperatorId)">
								对话
								<u-badge :isDot="true" :show="item.msgNum > 0"></u-badge>
							</u-button>
						</view>
						<view style="width: 14%;margin-left: 10rpx;" v-if="item.btnShow">
							<u-button size="mini" type="success" plain text="回收" @click="collectAddOrder(item)"></u-button>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="test-box">
			<view class="h2-font">验机报告</view>
			<view class="line-box" v-for="(item, key) in testArr">
				<view>{{item.name}}</view>
				<view class="row-box" style="margin-top: 20rpx;flex-wrap: wrap;">
					<view :class="index === item.selIndex ? 'sel-item-box': 'item-box'" v-for="(it, index) in item.children">{{it.name}}</view>
				</view>
			</view>
		</view>
		
		<view style="height: 100rpx;"></view>
		
		<u-popup :show="spreadOpen"  @close="handleClose()" closeable>
			<view style="padding: 20rpx;">
				<view class="h2-font">发起追差</view>
				
				<view>
					<u-form label-width="65">
						<u-form-item label="金额" required>
							<u-input v-model="spreadPrice" placeholder="请输入追差金额" type="number"></u-input>
						</u-form-item>
					</u-form>
				</view>
				
				<u-button text="提交" type="success" @click="spreadOrder()"></u-button>
			</view>
		</u-popup>
		
		<u-popup :show="wOpen" @close="handleWColse()" closeable>
			<view style="width: 100%;height: 500rpx;text-align: center;margin-top: 100rpx;">
				<image src="@/static/withdraw.png" style="width: 400rpx;height: 400rpx;"></image>
				<view style="width: 100%;text-align: center;font-size: 30rpx;font-weight: 900;">
					提现码: {{detailInfo.id}}
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import $path from "@/utils/ServerPath.js"
	export default {
		data() {
			return {
				wOpen: false,
				//文件
				fileList: [],
				spreadOpen: false,
				//追差金额
				spreadPrice: 0,
				form: null,
				detailInfo: {
					fileUrls: [],
					modelName: undefined,
					specs: undefined,
					iemi: undefined,
					createTime: undefined,
					offerOrderList: [],
					type: 0
				},
				priceSel: 0,
				priceList: [],
				userInfo: {
					type: undefined
				},
				//验机选项
				testArr: [],
				//中标详情
				centreInfo: undefined,
				//快递单号
				expressageNo: undefined,
				//询价id
				paramsId: undefined,
			}
		},
		onLoad(params) {
			this.getUserInfo();
			this.paramsId = params.id
			this.init();
		},
		onPullDownRefresh() {
			this.init();
		},
		methods: {
			//最高回收按钮
			collectBtnShow(list) {
				if(!list)
					return
				if(list.length === 1) {
					this.$set(list[0], "btnShow", true);
					return
				}
					
				let max = 0;
				let index = 0;
			
				list.forEach((item, key) => {
					if(item.status === 2 && !item.rateAmount) {
						if(Number(item.offerPrice) > max) {
							max = Number(item.offerPrice);
							index = key;
						}
					}else {
						if(Number(item.rateAmount) > max) {
							max = Number(item.rateAmount);
							index = key;
						}
					}
				})
				this.$set(list[index], "btnShow", true);
			},
			
			handleSpread() {
				this.spreadOpen = true;
				this.spreadPrice = 0;
			},
			handleWColse() {
				this.wOpen = false;
			},
			/* 关闭修改密码弹窗 */
			handleClose() {
				this.spreadOpen = false;
				this.spreadPrice = undefined
			},
			// 前往打款界面
			gotoWithdraw() {
				uni.navigateTo({
					url: "/pages/public/withdraw?id=" + this.detailInfo.id,
				})
			},
			handleWithdraw() {
				this.wOpen = true;
			},
			spreadOrder() {
				if(!this.spreadPrice) {
					uni.showToast({
						title: "请输入金额",
						icon:"error"
					})
					return;
				}
				if(Number(this.spreadPrice) <= 0) {
					uni.showToast({
						title: "金额须大于零",
						icon:"error"
					})
					return;
				}
				uni.showModal({
					title:"提示",
					content: "确定发起追差吗？",
					success: (res) => {
						const data = {
							recycleOrderId: this.detailInfo.recycleOrderVo.id,
							spread: Number(this.spreadPrice)
						}
						if(res.confirm) {
							this.$request("/appRecoverApi/order/addSpreadOrder","post", data).then(resp => {
								uni.showToast({
									title:"操作成功",
									icon:"success"
								})
								this.init();
								this.handleClose();
							})
						}
					}
				})
			},
			handleSpreadOrder(status) {
				let str = "";
				switch(status) {
					case 2: 
					str = "确定通过吗(并上传支付截图)？";
					if(this.fileList.length == 0) {
						uni.showToast({
							title:"请上传支付凭证截图",
							icon:"none"
						})
						return
					}
					;break;
					case 3: str = "确定收到追查金额吗?";break;
					case 4: str = "确定拒绝追差订单吗?";break;
				}
				
				uni.showModal({
					title:"提示",
					content: str,
					success: (res) => {
						if(res.confirm) {
							const data = {
								id: this.detailInfo.recycleOrderVo.spreadOrderVo.id,
								status: status,
								payImg: undefined
							}
							if(status === 2) {
								data.payImg = this.fileList[0].url;
							}
							this.$request("/appRecoverApi/order/updateSpreadOrder","post", data).then(resp => {
								uni.showToast({
									title: "操作成功",
									icon: "success"
								})
								this.init();
							})
						}
					}
				})
				
				//updateSpreadOrder
			},
			// 修改订单状态
			handleRefund(status) {
				let str = "";
				if(status === 2)
					str = "确定通过退单吗？";
				else if(status === 3)
					str = "确定完成退单吗？";
				else if(status === 4)
					str = "确定拒绝退单吗？";
				else
					return
				uni.showModal({
					title:"提示",
					content: str,
					success: (res) => {
						if(res.confirm) {
							const data = {
								refundOrderId: this.detailInfo.recycleOrderVo.refundOrderVo.id,
								status: status
							}
							this.$request("/appShopApi/order/updateRefundOrderStatus", "get", data).then(resp => {
								uni.showToast({
									title: "操作成功",
									icon: "success"
								})
								this.init();
							})
						}
					}
				})
			},
			getStepNumber() {
				let num = this.detailInfo.recycleOrderVo.refundOrderVo.status;
				num = num ? num - 1 : 0;
				return num;
			},
			getStepNumberS() {
				let num = this.detailInfo.recycleOrderVo.spreadOrderVo.status;
				num = num ? num - 1 : 0;
				return num;
			},
			/* 申请退单 */
			refundOrder() {
				uni.showModal({
					content: "确定与对方沟通好了退单吗？",
					title: "提示",
					success: (res) => {
						const data = {
							recycleOrderId: this.detailInfo.recycleOrderVo.id
						}
						if(res.confirm) {
							this.$request("/appRecoverApi/order/refundOrderCreate", "get", data).then(res => {
								uni.showToast({
									title: "操作成功！",
									icon: "success"
								})
								uni.$emit("orderFlush");
								uni.navigateBack({delta: 1})
							})
						}
					}
				})
			},
			/* 确认回收 */
			collectOk() {
				let status = this.detailInfo.recycleOrderVo.status;
				if(status !== 3) {
					uni.showToast({
						title: "订单状态错误",
						icon: "error"
					})
					return
				}
				const data = {
					id: this.detailInfo.recycleOrderVo.id,
					status: 4
				}
				this.$request("/appRecoverApi/order/recycleOrderConfirmReceiving", "post", data).then(res => {
					uni.showToast({
						title: "操作成功！",
						icon: "success"
					})
					uni.$emit("InquiryOrderFlush");
					uni.navigateBack({delta: 1})
				})
			},
			/* 发货 或 取消 3=发货 5=取消 */
			updateOrderStatus(e) {
				const data = {
					id: this.detailInfo.recycleOrderVo.id,
					status: e,
					expressageNo: this.expressageNo
				}
				if(e === 3) {
					if(!data.expressageNo) {
						uni.showToast({
							title: "请输入快递单号",
							icon: "error"
						})
						return
					}
				}
				
				this.$request("/appShopApi/order/recycleOrderStaUpdate", "post", data).then(res => {
					uni.showToast({
						title: "操作成功",
						icon: "success"
					})
					
					uni.$emit("orderFlush");
					uni.$emit("InquiryOrderFlush");
					uni.navigateBack({delta: 1})
				})
			},
			/* 支付接口 */
			paymentOrder() {
				const price = this.form.offerPrice;
				uni.showModal({
					title: "提示",
					content: "确定支付金额 " + price + " 元吗？",
					success: (res) => {
						if(res.confirm) {
							const orderInfo = this.detailInfo.recycleOrderVo;
							if(!orderInfo) {
								uni.showToast({
									title: "没有回收订单信息",
									icon: "none"
								})
								return
							}
							let orderId = orderInfo.id;
							if(orderInfo.status !== 1) {
								orderId = orderInfo.spreadOrderVo.id;
							}
							if(!orderId) {
								uni.showToast({
									title: "订单错误",
									icon: "none"
								})
							}
							this.$request("/appCommon/confirmPay", "get", {orderId: orderId}).then(res => {
								uni.showToast({
									title: "支付成功",
									icon:"success"
								})
								uni.$emit("quoterIndexFlush");
								uni.navigateBack({delta: 1})
							})
						}
					}
				})
			},
			// 创建回收订单
			collectAddOrder(row) {
				let price = row.rateAmount ? row.rateAmount : row.offerPrice;
				uni.showModal({
					title: "提示",
					content: "确定创建回收订单吗（￥"+ price +"）？",
					success: (res) => {
						if(res.confirm) {
							const data = {
								inquiryOrderId: this.detailInfo.id,
								offerOrderId: row.id
							}
							this.$request("/appShopApi/order/inquiryBindOfferOrder", "get", data).then(res => {
								uni.$emit("InquiryOrderFlush");
								uni.navigateBack({delta: 1})
							})
						}
					}
				})
			},
			/* 前往消息页面 */
			gotoMessage(id, receiveUser) {
				this.init();
				uni.navigateTo({
					url: "/pages/public/message?" 
						+ "inquiryOrderId="+ this.detailInfo.id 
						+ "&offerOrderId=" + id
						+ "&receiveUser=" + receiveUser
				})
			},
			//报价金额提交
			handleUpdateOffer() {
				if(!this.form.offerPrice) {
					uni.showToast({
						title: "金额不能为空",
						icon: "error"
					})
					return
				}
				this.$request("/appRecoverApi/order/updateOfferOrder", "post", this.form).then(res => {
					uni.showToast({
						title:"操作成功",
						icon: "success"
					})
					uni.$emit("quoterIndexFlush");
				})
			},
			// 获取用户信息
			getUserInfo() {
				this.userInfo = uni.getStorageSync(this.$constant.ROLE_INFO_KEY)
			},
			handleImage(e){
				uni.previewImage({
					current: e,
					urls: this.detailInfo.fileUrls
				})
			},
			handleImageOne() {
				uni.previewImage({
					current: 0,
					urls: [this.detailInfo.recycleOrderVo.spreadOrderVo.payImg]
				})
			},
			//判断是否询价中
			verityTime() {
				let now = new Date().getTime();
				let ten = 1000*60*10;
				let time = new Date(this.detailInfo.createTime).getTime();
				return now > (time + ten);
			},
			/* 报价初始化  询价状态  */
			init(id) {
				this.$request("/appShopApi/order/queryInquiryOrderDetail", 'get', {inquiryOrderId: this.paramsId}).then(res => {
					uni.stopPullDownRefresh();
					this.detailInfo = res.data;
					this.detailInfo.specs = this.detailInfo.specs.replaceAll(",", " ")
					//回收订单不为空 获取中标
					this.getCentreInfo();
					if(this.detailInfo.recycleOrderVo) {
						if(this.detailInfo.recycleOrderVo.refundOrderVo && this.detailInfo.recycleOrderVo.refundOrderVo.length > 0) {
							this.detailInfo.recycleOrderVo.refundOrderVo = this.detailInfo.recycleOrderVo.refundOrderVo[0]
						}else {
							this.detailInfo.recycleOrderVo.refundOrderVo = null
						}
						if(this.detailInfo.recycleOrderVo.spreadOrderVo && this.detailInfo.recycleOrderVo.spreadOrderVo.length > 0) {
							this.detailInfo.recycleOrderVo.spreadOrderVo = this.detailInfo.recycleOrderVo.spreadOrderVo[0]
						}else {
							this.detailInfo.recycleOrderVo.spreadOrderVo = null
						}
					}
					this.getTestOptions(res.data.modelVo, res.data.verifyOptionIds);
					//报价师角色
					if(this.userInfo.role === this.$constant.ROLE_QUOTER) {
						// 创建报价信息
						if(this.detailInfo.offerOrderList.length === 0) {
							this.createOfferOrder();
						}else {
							let bool = false;
							let createBool = true;
							for(let i = 0; i < this.detailInfo.offerOrderList.length; i++) {
								let it = this.detailInfo.offerOrderList[i];
								//同门下是否有报价
								if(it.offerBusId === this.userInfo.recoveryId) {
									createBool = false;
									//是否是我的报价
									if(it.offerOperatorId === this.userInfo.id) {
										this.form = it;
										bool = false
									}else {
										bool = true;
									}
								}
								
							}
							//同门有人报价时
							if(bool) {
								uni.showModal({
								cancelText: "退出",
								confirmText: "确定",
								content: "已有人报价，确定参与吗？",
								title: "提示",
								success: (res) => {
									if(res.confirm) {
										this.createOfferOrder();
									}else {
										uni.navigateBack({delta: 1})
									}
								}
								})
							}
							//不是同门无人报价
							if(createBool) {
								this.createOfferOrder();
							}
							
						}
					}else {
						this.collectBtnShow(this.detailInfo.offerOrderList);
					}
				})
			},
			//获取中标信息
			getCentreInfo() {
				if(this.detailInfo.offerId) {
					for(let i = 0; i < this.detailInfo.offerOrderList.length; i++) {
						let item = this.detailInfo.offerOrderList[i];
						if(item.id === this.detailInfo.offerId) {
							this.centreInfo = item;
							break
						}
					}
				}
			},
			/* 创建报价订单 */
			createOfferOrder() {
				if(this.detailInfo.offerId)
					return;
				const data = {
					inquiryOrderId: this.detailInfo.id
				}
				this.$request("/appRecoverApi/order/addOfferOrder", "post", data).then(res => {
					this.form = res.data;
				})
			},
			/* 获取验机选项 */
			getTestOptions(e, ids) {
				const params = {
					modelType: e.modelType,
					systemType: e.systemType
				}
				let specsSet = new Set();
				e.specsJson = JSON.parse(e.specsJson);
				e.specsJson.forEach(it => {
					specsSet.add(it[0])
					specsSet.add(it[1])
				})
				this.$request("/appCommon/model/options", 'get', params).then(res => {
					this.testArr = [];
					let specsArr = []; //规格列表
					let testArr = []; //验机列表
					let specsChid = [];
					let testChid = [];
					res.data.forEach(it => {
						if(it.type === 1) {
							if(specsSet.has(it.id)) {
								//规格
								if(it.parentId === 0)
									specsArr.push(it);
								else
									specsChid.push(it);
							}
						}else if(it.type === 2) {
							//验机
							if(it.parentId === 0)
								testArr.push(it);
							else
								testChid.push(it);
						}
					})
					this.setChildren(specsArr, specsChid);
					this.setChildren(testArr, testChid);
					this.testArr.push(...specsArr);
					this.testArr.push(...testArr);
					
					//设置选中数据
					this.testArr.forEach(pit => {
						pit.children.forEach((cit, key) => {
							if(ids.indexOf(cit.id) > -1)
								pit.selIndex = key;
						})
					})
				})
			},
			//设置子集
			setChildren(pArr, cArr) {
				pArr.forEach(pit => {
					pit.children = [];
					pit.selIndex = null;
					cArr.forEach(cit => {
						if(cit.parentId == pit.id) {
							pit.children.push(cit);
						}
					})
				})
			},
			priceClick(key) {
				this.priceSel = key;
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList`].length
				lists.map((item) => {
					this[`fileList`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList`][fileListLen]
					this[`fileList`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result.url,
						fileId: result.fileId
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: $path.prefix + '/appCommon/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							console.log("文件上传回调信息：", JSON.parse(res.data).url)
							setTimeout(() => {
								resolve(JSON.parse(res.data))
							}, 1000)
						}
					});
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.info-box {
		padding: 20rpx;
		background-color: #fff;
		font-size: 30rpx;
	}
	.price-box {
		padding: 20rpx;
		background-color: #fff;
		margin-top: 5rpx;
		.item-box {
			padding: 20rpx;
			margin-top: 10rpx;
			border-radius: 20rpx;
		}
	}
	.test-box {
		padding: 20rpx;
		margin-top: 5rpx;
		background-color: #fff;
		.line-box {
			margin-top: 10rpx;
			padding: 20rpx;
			.item-box {
				margin-top: 10rpx;
				border: 1px solid #71d5a1;
				padding: 10rpx 20rpx;
				margin-right: 10rpx;
				border-radius: 20rpx;
				color: #19be6b;
				font-size: 26rpx;
			}
			.sel-item-box {
				margin-top: 10rpx;
				padding: 10rpx 20rpx;
				color: #fff;
				margin-right: 10rpx;
				border-radius: 20rpx;
				background-color: #19be6b;
				font-size: 26rpx;
			}
		}
	}
</style>
